//
//  UIControl+Anayltic.m
//  testCrashOC
//
//  Created by kai Du on 2021/3/9.
//

#import "UIControl+Anayltic.h"
#import <objc/runtime.h>
@implementation UIControl (Anayltic)


+ (void)load{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        SEL originalDidLoadSelector = @selector(sendAction:to:forEvent:);
        SEL swizzingDidLoadSelector = @selector(analytic_sendAction:to:forEvent:);
        Method  fromMethod = class_getInstanceMethod([self class], originalDidLoadSelector);
           //需要交换的自己写的方法
           Method  toMethod = class_getInstanceMethod([self class], swizzingDidLoadSelector);
   
        method_exchangeImplementations(fromMethod, toMethod);
    });
}
- (void)analytic_sendAction:(SEL)action to:(id)target forEvent:(UIControlEvents *)event{
    NSString * name  =NSStringFromSelector(action);
    NSString *targetName = NSStringFromClass([target class]);
}
@end
